********************************************************************************
* Replication file for the online appendices of the paper:					   *
* Defending the Status Quo or Seeking Change?								   *
* 	Electoral Outcomes, Affective Polarisation, and Support for Referendums	   *
* Date: 20 March 2025														   *
* Authors: Bjarn Eck & Emilien Paulis										   *
********************************************************************************

*** Set working directory yourself
*** packages: estout (ssc install estout, replace)

*** Open dataset 
	use "dataset", replace 

	
//==============================================================================	
// A. DETAILS ON THE DATA
//==============================================================================	

*** 1. Countries and respondents
	tab country

*** 2. Summary statistics 
	sum referendum winlose AP polint lr efficacy gender age education employment 
	
//==============================================================================	
// B. ROBUSTNESS CHECKS 
//==============================================================================


*** 1. Ordered logit models
	est clear
	global controls polint lr efficacy gender age education i.employment i.country
	
  
	* M0: Base model
	ologit referendum winlose AP, vce(r)
	est store m1
	
	* M1: Add IVs
	ologit referendum winlose AP $controls , vce(r)
	est store m2
	
	* M2: Add interactions
	ologit referendum winlose##c.AP $controls , vce(r)
	est store m3

	
	esttab m1 m2 m3, ///
		scalars (N) label se nobase noomitted b(%9.3f) se(%9.3f) sfmt(%9.3f) wide ///
		star(* 0.05 ** 0.01 *** 0.001) obslast order(winlose AP *.winlose#c.AP) ///
		interaction(*) mti("M1" "M2" "M3") nonum drop(*.country)
	  

	
  
*** 2. Include controls for SWD 
	est clear
	global controls polint lr efficacy gender age education i.employment i.country swd 
 
	* M0: Base model
	reg referendum winlose AP, vce(r)
	est store m1
	
	* M1: Add IVs
	reg referendum winlose AP $controls , vce(r)
	est store m2
	
	* M2: Add interactions
	reg referendum winlose##c.AP $controls , vce(r)
	est store m3
	
	esttab m1 m2 m3, ///
		scalars (N r2_a) label se nobase noomitted b(%9.3f) se(%9.3f) sfmt(%9.3f) wide ///
		star(* 0.05 ** 0.01 *** 0.001) obslast order(winlose AP *.winlose#c.AP) ///
		interaction(*) mti("M1" "M2" "M3") nonum drop(*.country)

		
*** 3. Same analyses with separate DVs
	
	* T-tests
	bys country: ttest ref_force, by(winlose) rev
	bys country: ttest ref_important, by(winlose) rev
	
	* Regression models 
	est clear
	global controls polint lr efficacy gender age education i.employment i.country 
	
	reg ref_force winlose AP, vce(r)
	est store m1_force
	reg ref_force winlose AP $controls , vce(r)
	est store m2_force
	reg ref_force winlose##c.AP $controls , vce(r)
	est store m3_force
	
	reg ref_important winlose AP, vce(r)
	est store m1_important
	reg ref_important winlose AP $controls , vce(r)
	est store m2_important
	reg ref_important winlose##c.AP $controls , vce(r)
	est store m3_important
	
	esttab m1_force m2_force m3_force m1_important m2_important m3_important,  ///
		scalars (N r2_a) label se nobase noomitted b(%9.3f) se(%9.3f) sfmt(%9.3f)  ///
		star(* 0.05 ** 0.01 *** 0.001) obslast order(winlose AP *.winlose#c.AP) ///
		interaction(*) mti("M1" "M2" "M3" "M1" "M2" "M3") nonum drop(*.country)	

		
*** 4. Control for PRR vote 
	est clear
	global controls polint lr efficacy gender age education i.employment i.country prr

	* M0: Base model
	reg referendum winlose AP, vce(r)
	est store m1
	
	* M1: Add IVs
	reg referendum winlose AP $controls, vce(r)
	est store m2
	
	* M2: Add interactions
	reg referendum winlose##c.AP $controls, vce(r)
	est store m3
	
	esttab m1 m2 m3, ///
		scalars (N r2_a) label se nobase noomitted b(%9.3f) se(%9.3f) sfmt(%9.3f)  ///
		star(* 0.05 ** 0.01 *** 0.001) obslast order(winlose AP *.winlose#c.AP) ///
		interaction(*) mti("M1" "M2" "M3") wide nonum drop(*.country)

		
	
*** 5. Include abstainers  
	est clear
	global controls polint lr efficacy gender age education i.employment i.country 
	
	* M0: Base model
	reg referendum winlose_abstain AP, vce(r)
	est store m1
	
	* M1: Add IVs
	reg referendum winlose_abstain AP $controls , vce(r)
	est store m2
	
	* M2: Add interactions
	reg referendum winlose_abstain##c.AP $controls , vce(r)
	est store m3
	

	esttab m1 m2 m3, ///
		scalars (N r2_a) label se nobase noomitted b(%9.3f) se(%9.3f) sfmt(%9.3f)  ///
		star(* 0.05 ** 0.01 *** 0.001) obslast ///
		order(winlose_abstain AP *.winlose_abstain#c.AP) ///
		interaction(*) mti("M1" "M2" "M3") wide nonum drop(*.country)

		
*** 6. Control for structural electoral loss
	est clear
	global controls polint lr efficacy gender age education i.employment i.country winlose_previous  

	* M0: Base model
	reg referendum winlose AP, vce(r)
	est store m1
	
	* M1: Add IVs
	reg referendum winlose AP $controls, vce(r)
	est store m2

	* M2: Add interactions
	reg referendum winlose##c.AP $controls, vce(r)
	est store m3
	
	esttab m1 m2 m3, ///
		scalars (N r2_a) label se nobase noomitted b(%9.3f) se(%9.3f) sfmt(%9.3f)  ///
		star(* 0.05 ** 0.01 *** 0.001) obslast order(winlose AP *.winlose#c.AP) ///
		interaction(*) mti("M1" "M2" "M3") wide nonum drop(*.country)		

		
		
*** 7. Control for party size vote 
	est clear
	global controls polint lr efficacy gender age education i.employment i.country party_size

	* M0: Base model
	reg referendum winlose AP, vce(r)
	est store m1
	
	* M1: Add IVs
	reg referendum winlose AP $controls, vce(r)
	est store m2
	
	* M2: Add interactions
	reg referendum winlose##c.AP $controls, vce(r)
	est store m3
	
	esttab m1 m2 m3, ///
		scalars (N r2_a) label se nobase noomitted b(%9.3f) se(%9.3f) sfmt(%9.3f)  ///
		star(* 0.05 ** 0.01 *** 0.001) obslast order(winlose AP *.winlose#c.AP) ///
		interaction(*) mti("M1" "M2" "M3") wide nonum drop(*.country)
		

		
		
*** 8. Control for all potential confounders
	est clear
	global controls polint lr efficacy gender age education i.employment i.country ///
		swd prr winlose_previous party_size

	* M0: Base model
	reg referendum winlose AP, vce(r)
	est store m1
	
	* M1: Add IVs
	reg referendum winlose AP $controls, vce(r)
	est store m2

	* M2: Add interactions
	reg referendum winlose##c.AP $controls, vce(r)
	est store m3

	esttab m1 m2 m3, ///
		scalars (N r2_a) label se nobase noomitted b(%9.3f) se(%9.3f) sfmt(%9.3f)  ///
		star(* 0.05 ** 0.01 *** 0.001) obslast order(winlose AP *.winlose#c.AP) ///
		interaction(*) mti("M1" "M2" "M3") wide nonum drop(*.country)
			
	
	
*** 9. Check difference between largest and junior coalition party
	est clear
	global controls polint lr efficacy gender age education i.employment i.country 

	* M0: Base model
	reg referendum ib0.coalition AP, vce(r)
	est store m1
	
	* M1: Add IVs
	reg referendum ib0.coalition AP $controls, vce(r)
	est store m2
	
	* M2: Add interactions
	reg referendum ib0.coalition##c.AP $controls, vce(r)
	est store m3
	
	esttab m1 m2 m3, ///
		scalars (N r2_a) label se nobase noomitted b(%9.3f) se(%9.3f) sfmt(%9.3f)  ///
		star(* 0.05 ** 0.01 *** 0.001) obslast order(coalition AP *.coalition#c.AP) ///
		interaction(*) mti("M1" "M2" "M3") wide nonum drop(*.country)
		




*** 10. Jackknife tests 
	* 10.1 Drop one country at a time
	est clear
	global controls polint lr efficacy gender age education i.employment i.country
	
	forval i = 1/13 {
		local country `i'
		local country_label : label(country) `country'
		reg referendum winlose AP $controls  if country!=`country' 
		est store `country_label'
		}	

	coefplot (WAL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Wallonia")) ///
		(FL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Flanders")) ///
		(CZ, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Czech Republic")) ///
		(DK, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Denmark")) ///
		(FI, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Finland")) ///
		(FR, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="France")) ///
		(DE, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Germany")) ///
		(GR, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Greece")) ///
		(IR, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Ireland")) ///
		(NL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Netherlands")) ///
		(PL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Poland")) ///
		(ES, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Spain")) ///
		(UK, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="UK")), ///
		xline(0, lcolor(black) lp(dash)) ///
		xsc(r(0(0.1)0.3)) xlab(0(0.1)0.3) ///
		nokey
		
		
	est clear
	global controls polint lr efficacy gender age education i.employment i.country
	
	forval i = 1/13 {
			local country `i'
			local country_label : label(country) `country'
			reg referendum winlose##c.AP $controls if country!=`country', r
			est store `country_label'
		}	
	
	coefplot (WAL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Wallonia")) ///
		(FL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Flanders")) ///
		(CZ, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Czech Republic")) ///
		(DK, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Denmark")) ///
		(FI, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Finland")) ///
		(FR, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="France")) ///
		(DE, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Germany")) ///
		(GR, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Greece")) ///
		(IR, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Ireland")) ///
		(NL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Netherlands")) ///
		(PL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Poland")) ///
		(ES, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Spain")) ///
		(UK, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="UK")), ///
		xline(0, lcolor(black) lp(dash)) ///
		xsc(r(0(0.05)0.2)) xlab(0(0.05)0.2) ///
			nokey

			
	* 10.2 By-country analysis
	est clear
	global controls polint lr efficacy gender age education i.employment
	
	forval i = 1/13 {
		local country `i'
		local country_label : label(country) `country'
		reg referendum winlose AP $controls  if country==`country' 
		est store `country_label'
		}	

	coefplot (WAL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Wallonia")) ///
		(FL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Flanders")) ///
		(CZ, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Czech Republic")) ///
		(DK, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Denmark")) ///
		(FI, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Finland")) ///
		(FR, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="France")) ///
		(DE, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Germany")) ///
		(GR, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Greece")) ///
		(IR, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Ireland")) ///
		(NL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Netherlands")) ///
		(PL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Poland")) ///
		(ES, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="Spain")) ///
		(UK, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose) rename(winlose="UK")), ///
		xline(0, lcolor(black) lp(dash)) ///
		xsc(r(0(0.1)0.6)) xlab(0(0.1)0.6) ///
		nokey


		
		
	est clear
	global controls polint lr efficacy gender age education i.employment 
	
	forval i = 1/13 {
			local country `i'
			local country_label : label(country) `country'
			reg referendum winlose##c.AP $controls if country==`country', r
			est store `country_label'
		}	
	
	coefplot (WAL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Wallonia")) ///
		(FL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Flanders")) ///
		(CZ, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Czech Republic")) ///
		(DK, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Denmark")) ///
		(FI, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Finland")) ///
		(FR, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="France")) ///
		(DE, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Germany")) ///
		(GR, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Greece")) ///
		(IR, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Ireland")) ///
		(NL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Netherlands")) ///
		(PL, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Poland")) ///
		(ES, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="Spain")) ///
		(UK, m(O) mc(black) ciopts(lcolor(black)) ///
		keep(*winlose#c.AP) rename(1.winlose#c.AP="UK")), ///
		xline(0, lcolor(black) lp(dash)) ///
		xsc(r(-0.2(0.1)0.5)) xlab(-0.2(0.1)0.5) ///
			nokey